<%@page contentType="text/html;charset=utf-8"%>
<%@include file="../../core/common.jsp"%>
<html>
<head>
<title></title>
</head>
<body>
	<div class="easyui-panel" data-options="fit:true,border:false,footer:'#fb'">
		<form id="fm">
			<input name="cpbh" type="hidden">
			<input id="json" name="json" type="hidden">
			<table class="form-layout w80 p-t-10 p-r-30 p-b-10">
				<tr>
					<td>分析时间：</td>
					<td><input name="fxsj" class="easyui-datebox" data-options="editable:false,required:true" /></td>
					<td>检查者：</td>
					<td><input name="jcz" class="easyui-textbox" data-options="required:true" validType="maxLength[32]" /></td>
					<td>确认者：</td>
					<td><input name="qrz" class="easyui-textbox" data-options="required:true" validType="maxLength[32]" /></td>
				</tr>
			</table>
		</form>
		<table id="eg" class="easyui-edatagrid" data-options="url:'${CTX}/mgt/t/fxd/ckfx/find?cpbh=${param.cpbh}',border:true,fit:false">
			<thead>
				<tr>
					<th data-options="field:'cpbh',width:200">产品编号</th>
					<th data-options="field:'ys',width:200">元素名称</th>
					<th data-options="field:'rkfx',width:200">入库分析</th>
					<th data-options="field:'ckfx',width:200" editor="{type:'textbox',options:{required:true,validType:'maxLength[50]'}}">出库分析</th>
				</tr>
			</thead>
		</table>
	</div>
	<div id="fb">
		<a id="save" class="form-btn success">确定</a>
	</div>
</body>
<script>
	$(function() {
		$('#fm').form('load', '${CTX}/mgt/t/rkd/get?id=${param.cpbh}');
		$('#save').click(function() {
			if (!$('#fm').form('validate')) {
				return;
			}
			var data = $('#eg').edatagrid('getRows');
			for ( var i in data) {
				var rowIndex = $('#eg').edatagrid('getRowIndex', data[i]);
				$('#eg').edatagrid('beginEdit', rowIndex);
				if (!$('#eg').edatagrid('validateRow', rowIndex)) {
					return;
				}
				$('#eg').edatagrid('endEdit', rowIndex);
			}
			$('#json').val(JSON.stringify(data));
			$.mask();
			$.ajax({
				url : '${CTX}/mgt/t/fxd/ckfx',
				data : $('#fm').serialize(),
				success : function(data) {
					$.unmask();
					$.handle(data, function() {
						$.close();
					});
				}
			});
		});
	});
</script>
</html>